package paper.web.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * <p>Class       : paper.web.controller.LoginController
 * <p>Descdription: 登录跳转逻辑控制器
 * @author  顾力行-gulixing@msn.com
 * @version 1.0.0
 */
@Controller
public class LoginController extends BaseController {
    
	/**
	 * <p>Method ：login
	 * <p>Description : 处理登录跳转请求
	 * @return 
	 * @author  gulixing@msn.com
	 * @version 1.0.0
	 */
	@RequestMapping(value = "/login", method = RequestMethod.GET)
	public String login() {
		return "login";
	}

    /**
     * <p>
     * Method ：registPost
     * <p>
     * Description : 首页
     * 
     * @return
     * @author gulixing@msn.com
     * @version 1.0.0
     */
    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public String index(Model model) {
        if (getCurrentUser() != null) {
            model.addAttribute("user", getCurrentUser());
            return "index";
        }
        return "login";
    }

    /**
     * <p>
     * Method ：loginSuccess
     * <p>
     * Description : 处理登录成功
     * 
     * @param model
     * @return
     * @throws Exception
     * @author 顾力行-gulixing@msn.com
     */
    @RequestMapping(value = "/loginsuccess", method = RequestMethod.GET)
    public String loginSuccess(HttpServletRequest request) throws Exception {
    	//未填写组织机构信息
    	if(getCurrentAccount().getUnit()==null){
            //强制完成个人信息
            return  redirectToUrl("/paper/user/update");
       }
        return "index";
    }
    
}